package com.hhm.huo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 实现接口---全局跨域
 */
@Configuration//注解类
public class MyWebConfig implements WebMvcConfigurer {
    // 全局跨域配置
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowCredentials(true)//允许带上认证信息
                .allowedOrigins("*")//允许搜狐等访问--请求的任何源
                .allowedMethods("GET","POST","PUT","DELETE","HEAD")//方法
                .maxAge(3600);//生命周期
    }
}
